Fix formatting issue with code block opening braces#11969
Fix formatting issue with code block opening braces#11969davidwengier merged 6 commits intodotnet:mainfrom
Conversation
…ptions exhaustively-ish
DustinCampbell
left a comment
There was a problem hiding this comment.
I'm definitely in favor of the auto-generated tests.
|
Have we considered writing some fuzz tests for the formatter? Essentially start with a well formatted document, apply some set of randomized but controlled changes, and run the formatter to make sure it gets back to the formatted state? Don't know if that adds value or is even possible, but figured it might be worth looking at. |
|
Definitely thought about it a lot, never quite had to time or concreteness of ideas to put fingers on keyboards. I've tried a few different times to get copilot to write some tests, and found the same thing Fred did in his recent attempt, where it mostly just generates tests that have " |
Fixes #11970
(which is really https://developercommunity.visualstudio.com/t/Razor-file-formatting-throws-ran-out-of/10924272)
((which is really https://dev.azure.com/devdiv/DevDiv/_workitems/edit/2508457))
Seems I missed a case in my previous fix, which is where Roslyn is configured for K&R braces, but the Razor file is not.
In order to track this down, I experimented with automatically generating tests to provide cover for the C# syntax formatting options. I referred to that coverage as "exhaustive", but quickly met with this thing called "Math" which said that would be too many tests, so I toned it down. The last two commits are the generator and the tests.
I'm not convinced they're adding any value, now that I've found the issue and created real targeted tests for the same thing, in our normal formatting test class, but I left them anyway. Copilot wrote most of the generator anyway, so its not a big deal to recreate it again, if anyone thinks it shouldn't be there. Let me know.